<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2018/1/16
 * Time: 13:17
 */
namespace app\inter\logic;

use app\admin\model\BankModel;
use app\inter\model\CarInfoRModel;
use app\inter\model\DistanceModel;
use app\inter\model\DriverApplicationModel;
use app\inter\model\DriverBankModel;
use app\inter\model\DriverMoneyLogModel;
use app\inter\model\DriverMoneyModel;
use app\inter\model\GetMoneyRecordModel;
use app\inter\model\InvActModel;
use think\Model;
class PersonalLogic extends Model
{
    /**
     * 获取司机收入流水
     * @param $map
     * @param $field
     * @param $flag //true返回二维数组，false返回一维数组
     * @param $page
     * @param $limit
     * @return array|false
     * */
    public function getDriverMoneyLog($map,$field='*',$flag=true,$page=1,$limit=10)
    {
        $log = new DriverMoneyLogModel();
        return $log->getLog($map,$field,$flag,$page,$limit);
    }

    /**
     * 添加司机账户变动信息
     * @param $data
     * @return  string|false
     * */
    public function createDriverMoneyLog($data)
    {
        $driver_model = new DriverMoneyLogModel();
        return $driver_model->addLog($data);
    }

    /**
     * 获取司机余额记录
     * @param $map
     * @param $field
     * @param $flag
     * @param $page
     * @param $limit
     * @return  array|false
     * */
    public function getDriverMoney($map,$field='a.*',$flag=true,$page=1,$limit=10)
    {
        $money = new DriverMoneyModel();
        return $money->getDriverMoney($map,$field,$flag,$page,$limit);
    }


    /**
     * 根据司机id获取司机余额记录
     * @param $driver_id
     * @return  array|false
     * */
    public function getDriverMoneyById($driver_id)
    {
        $money = new DriverMoneyModel();
        return $money->getDriverMoney(array('driver_id'=>$driver_id),'a.*',false);
    }

    /**
     * 更新司机账户余额
     * @param $map
     * @param $data
     * @return  string|false
     * */
    public function renewDriverMoney($map,$data)
    {
        if(empty($data)){
            return false;
        }
        $driver_bank = new DriverMoneyModel();
        return $driver_bank->updateMoney($map,$data);
    }

    /**
     * 获取司机银行卡信息
     * @param $map
     * @param $field
     * @param $flag //true返回二维数组，false返回一维数组
     * @param $page
     * @param $limit
     * @return array|false
     * */
    public function getDriverBank($map,$field='a.*',$flag=true,$page=1,$limit=10)
    {
        $log = new DriverBankModel();
        return $log->getDriverBank($map,$field,$flag,$page,$limit);
    }


    /**
     * 根据司机id获取司机银行卡信息
     * @param $driver_id
     * @param $field
     * @return  array|false
     * */
    public function getDriverBankById($driver_id,$field='a.*')
    {
        $money = new DriverBankModel();
        return $money->getDriverBank(array('a.driver_id'=>$driver_id,'a.is_del'=>2),$field,false);
    }

    /**
     * 添加司机银行卡信息
     * @param $data
     * @return  string|false
     * */
    public function createDriverBank($data)
    {
        $driver_bank = new DriverBankModel();
        return $driver_bank->addDriverBank($data);
    }

    /**
     * 获取银行卡信息
     * @param $map
     * @param $field
     * @param $flag //true返回二维数组，false返回一维数组
     * @param $page
     * @param $limit
     * @return array|false
     * */
    public function getBank($map=array(),$field='*',$flag=true,$page=1,$limit=10)
    {
        $bank = new BankModel();
        return $bank->getBank($map,$field,$flag,$page,$limit);
    }

    /**
     * 获取司机提现申请信息
     * @param $map
     * @param $field
     * @param $flag //true返回二维数组，false返回一维数组
     * @param $page
     * @param $limit
     * @return array|false
     * */
    public function getDriverApplication($map=array(),$field='da.*',$flag=true,$page=1,$limit=10)
    {
        $bank = new DriverApplicationModel();
        return $bank->getApplication($map,$field,$flag,$page,$limit);
    }

    /**
     * 添加司机提现申请
     * @param $data
     * @return  string|false
     * */
    public function createDriverApplication($data)
    {
        $driver_bank = new DriverApplicationModel();
        return $driver_bank->addApplication($data);
    }

    /**
     * 更新司机提现申请
     * @param $map
     * @param $data
     * @return  string|false
     * */
    public function renewDriverApplication($map,$data)
    {
        if(empty($data)){
            return false;
        }
        $driver_bank = new DriverApplicationModel();
        return $driver_bank->updateApplication($map,$data);
    }

    /**
     * 更新司机银行卡信息
     * @param $map
     * @param $data
     * @return  string|false
     * */
    public function renewDriverBank($map,$data)
    {
        if(empty($data)){
            return false;
        }
        $driver_bank = new DriverBankModel();
        return $driver_bank->updateDriverBank($map,$data);
    }















}